package com.ionehe.group.common.notify.rocketmq.factory;

import com.ionehe.group.common.notify.configure.NotifyConfiguration;
import com.ionehe.group.common.notify.message.consumer.Consumer;
import com.ionehe.group.common.notify.message.consumer.OrderConsumer;
import com.ionehe.group.common.notify.message.factory.Factory;
import com.ionehe.group.common.notify.message.producer.OrderProducer;
import com.ionehe.group.common.notify.message.producer.Producer;
import com.ionehe.group.common.notify.message.producer.TransactionProducer;
import com.ionehe.group.common.notify.rocketmq.consumer.ConsumerImpl;
import com.ionehe.group.common.notify.rocketmq.consumer.OrderConsumerImpl;
import com.ionehe.group.common.notify.rocketmq.producer.OrderProducerImpl;
import com.ionehe.group.common.notify.rocketmq.producer.ProducerImpl;
import com.ionehe.group.common.notify.rocketmq.producer.TransactionProducerImpl;
import org.apache.rocketmq.client.producer.TransactionCheckListener;

import java.util.Properties;

/**
 * Copyright (c) 2021 ionehe.com
 * Date: 2021/4/21
 * Time: 1:22 下午
 *
 * @author 2021年 <a href="mailto:a@ionehe.com">秀</a>
 * 【rocketmq工厂】
 */
public class AsyncFactory implements Factory {
    private NotifyConfiguration configuration;

    public AsyncFactory(NotifyConfiguration configuration) {
        this.configuration = configuration;
    }


    @Override
    public Producer createProducer() {
        return (Producer) new ProducerImpl(this.configuration);
    }


    @Override
    public Consumer createConsumer() {
        return (Consumer) new ConsumerImpl(this.configuration);
    }


    @Override
    public OrderProducer createOrderProducer() {
        return (OrderProducer) new OrderProducerImpl(this.configuration);
    }


    @Override
    public OrderConsumer createOrderedConsumer() {
        return (OrderConsumer) new OrderConsumerImpl(this.configuration);
    }


    @Override
    public TransactionProducer createTransactionProducer(Properties properties, TransactionCheckListener checker) {
        return (TransactionProducer) new TransactionProducerImpl(properties, checker);
    }
}

